#!/usr/bin/python
# author dennis
# 2022年06月14日
import time
import multiprocessing


def coding():
    for i in range(3):
        print("coding...")
        time.sleep(0.2)


def music():
    for i in range(3):
        print("music...")
        time.sleep(0.2)


# 进程执行带有参数的任务
def coding1(num,name):
    for i in range(num):
        print(name)
        print("coding1...")
        time.sleep(0.2)


def play(name,age,**kwargs):
    print("子进程{}  {}:{}".format(name,age,kwargs))


if __name__ == '__main__':
    # 通过进程类创建进程对象
    coding_process = multiprocessing.Process(target=coding)
    music_process = multiprocessing.Process(target=music)
    coding1_process = multiprocessing.Process(target=coding1, args=(6,"传智"))
    play_process = multiprocessing.Process(target=play,args=("xiongda",5) ,kwargs={"count": 5})
    # 启动进程
    coding_process.start()
    coding_process.join()
    music_process.start()
    coding1_process.start()
    play_process.start()
    print("我是父进程")
